﻿function starRating(rating, obj)
    {
        switch(rating)
        {
            case 1:
                obj.parentNode.className = "star-rating one-star-rating";
                obj.parentNode.parentNode.childNodes[1].value = 1;
                break;
            case 2:
                obj.parentNode.className = "star-rating two-star-rating";
                obj.parentNode.parentNode.childNodes[1].value = 2;
                break;
            case 3:
                obj.parentNode.className = "star-rating three-star-rating";
                obj.parentNode.parentNode.childNodes[1].value = 3;
                break;
            case 4:
                obj.parentNode.className = "star-rating four-star-rating";
                obj.parentNode.parentNode.childNodes[1].value = 4;
                break;
            case 5:
                obj.parentNode.className = "star-rating five-star-rating";
                obj.parentNode.parentNode.childNodes[1].value = 5;
                break;
            default:
                break;
        }
    }
    
    function initRating(obj)
    {
        var curRating = obj.parentNode.childNodes[1].value;
        if (curRating == "")
        {
            obj.className = "star-rating";
            return;
        }
        if (curRating == "1")
        {
            obj.className = "star-rating one-star-rating";
            return;
        }
        if (curRating == "2")
        {
            obj.className = "star-rating two-star-rating";
            return;
        }
        if (curRating == "3")
        {
            obj.className = "star-rating three-star-rating";
            return;
        }
        if (curRating == "4")
        {
            obj.className = "star-rating four-star-rating";
            return;
        }
        if (curRating == "5")
        {
            obj.className = "star-rating five-star-rating";
            return;
        }
    }